package com.leetcode.algorithm.y22.m06;

/**
 * 852. 山脉数组的峰顶索引
 * 
 * https://leetcode.cn/problems/peak-index-in-a-mountain-array/
 * 
 * @author jie.deng
 *
 */
public class Question0852Solution01 {

	public int peakIndexInMountainArray(int[] arr) {
		int len = arr.length;
		int left = 0;
		int right = len - 1;
		while (left < right) {
			int mid = left + ((right - left) >> 1);
			if (arr[mid] < arr[mid + 1]) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return left;
	}

}
